package com.swust.exam.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.swust.exam.pojo.Questionbank;
import com.swust.exam.service.QuestionbankService;


@Controller
@RequestMapping(value="/questionbank")
public class QuestionbankController {
	@Autowired
	private QuestionbankService questionbankService;
	
	@RequestMapping(value = "/get")
	public Questionbank questionbankGet(int id){
		return questionbankService.get(id);
	}
	
	
	@RequestMapping(value="/delete")
	public int questionbankDelete(int id) {
		return questionbankService.delete(id);
	}
	
	@RequestMapping(value="/insert")
	public String questionbankInsert(Questionbank questionbank,Model model) {
		questionbankService.insert(questionbank);
		List<Questionbank> list=questionbankService.questionbanklist();
		model.addAttribute("questionbanklist",list);
		return "question";
	}
	
	@RequestMapping(value="/update")
	public int questionbankUpdate(Questionbank questionbank) {
		return questionbankService.update(questionbank);
	}
		

}
